// Have include guard.
#ifndef CONTROLLERSELECTORCONTROLLER_H
#define CONTROLLERSELECTORCONTROLLER_H

// Include files.
#include <string>
#include "Service.hpp"
#include "SelectorService.hpp"
#include "../ValueOutputs/ValueOutput.hpp"
#include "../ValueOutputs/NullValueOutput.hpp"

class SystematicRobot;

/**
 *  The ControllerSelectorService selects a Service to be run from a list based on some input.
 * 
 *  When ControllerSelectorService selects a new Service, it stops the one that was previously 
 *  selected (if any), and starts the newly select one.
 *  
 *  This is useful for switching driving modes based on the driver's preference.
 *  
 *  Testing shows this class mostly works.
 */
class ServiceSelectorService :
	public SelectorService<Service*>
{
	private:
		typedef Service *Item;
	public:
		ServiceSelectorService(HumanDigitalInput &upInput, HumanDigitalInput &downInput, ValueOutput<std::string> &valueOutput = NullValueOutput<std::string>::GetInstance());
		ServiceSelectorService(DriverStationEnhancedIO &driverStationIo, UINT32 buttonUp, UINT32 buttonDown, ValueOutput<std::string> &valueOutput = NullValueOutput<std::string>::GetInstance());
		
		virtual ~ServiceSelectorService();
	protected:
		virtual void HandleItemAdded(Service *service);
		virtual void HandleItemSelectedImpl(Service *service);
		virtual void HandleItemUnselectedImpl(Service *service);
};

#endif // #ifndef CONTROLLERSELECTORCONTROLLER_H
